var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isShowModal: false,
    userInfo: '',
    isLogin: false,
    nickName: '',
    avatarUrl: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var info = app.GetUserInfoMsg()
    if (info) {
      this.setData({
        isLogin: true,
        nickName: info.nickName,
        avatarUrl: info.avatarUrl
      })
    }
  },

  bindKefu: function() {
    console.log("AAAAAAAAAAAAAAAAA")
    this.setData({
      isShowModal: true
    })
  //  wx.navigateTo({
  //    url: '/pages/admin/managerData',
  //  })
  },
  bindContact: function() {
    this.setData({
      isShowModal: false
    })
  },
  onScore: function() {
    if (this.data.isLogin) {
      wx.navigateTo({
        url: '/pages/score/score',
      })
    } else {
      wx.navigateTo({
        url: '/pages/account/login',
      })
    }

  },

  bindGetUserInfo(e) {
    console.log("e====" + JSON.stringify(e.detail.userInfo))
    var that = this
    var info = e.detail.userInfo
    app.request.reqCloudLoading("login", {
      nickName: info.nickName,
      avatarUrl: info.avatarUrl
    }, function(res) {
      if (res.code == 0) {
        app.SetUserInfoMsg(info)
        that.setData({
          isLogin: true,
          nickName: info.nickName,
          avatarUrl: info.avatarUrl
        })
      } else {
        app.showToastMsg("登录失败")
      }
    })
  },
})